package player.state;

import player.MusicPlayer;
import jaco.mp3.player.MP3Player;
/**
 * Playing state of the music player.
 * @author Pawin Suthipornopas 5510546123
 */
public class PlayingState extends PlayerState {
	
	/**
	 * Constructor, create the playing state.
	 * @param player is the player to be played.
	 * @param musicPlayer is the MusicPlayer, use to change the state.
	 */
	public PlayingState(MP3Player player, MusicPlayer musicPlayer){
		super(player, musicPlayer);
	}

	@Override
	public void handlePlay() {
		player.stop();
		player.play();
		System.out.println("PlayingState_handlePlay");
	}

	@Override
	public void handleStop() {
		player.stop();
		musicPlayer.setState(musicPlayer.IDLE_STATE);
		System.out.println("PlayingState_handleStop");
	}
	
	@Override
	public void handlePause(){
		player.pause();
		musicPlayer.setState(musicPlayer.PAUSE_STATE);
		System.out.println("PlayingState_handlePause");
	}
	
	@Override
	public void handleNext() {
		player.stop();
		player.skipForward();
		player.play();
		System.out.println("PlayingState_handleNext");
	}

	@Override
	public void handlePrevious() {
		player.stop();
		player.skipBackward();
		player.play();
		System.out.println("PlayingState_handlePrevious");
	}
}
